package grape.workflow.rest.flowable.ui;

import grape.common.rest.advice.DisableGRB;
import grape.common.rest.advice.DisableGRM;
import org.flowable.ui.common.model.RemoteUser;
import org.flowable.ui.common.model.UserRepresentation;
import org.flowable.ui.common.security.SecurityUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 *
 * Created by yangwei
 * Created at 2020/6/3 16:30
 */
@RestController
@RequestMapping("/app") // flowable原生扩展，不加前缀
public class AccountController {
    @DisableGRM
    @DisableGRB
    @GetMapping(value = "/rest/account")
    public UserRepresentation getAccount() {
        RemoteUser currentUserObject = (RemoteUser)SecurityUtils.getCurrentUserObject();

        UserRepresentation userRepresentation = new UserRepresentation();
        userRepresentation.setId(currentUserObject.getId());
        userRepresentation.setPrivileges(currentUserObject.getPrivileges());
        return userRepresentation;
    }
}
